﻿using System;
using System.IO;
using System.Windows.Forms;

namespace DataViewer
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // 初始化配置
            var config = new Config();
            config.InitializeFolders();

            Application.Run(new FormShowData(config));
        }
    }

    public class Config
    {
        // 基础数据文件夹
        private readonly string BaseDataFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");

        // CSV文件夹
        public string CsvFolder => Path.Combine(BaseDataFolder, "csv");

        // 图片文件夹
        public string[] ImageFolders => new[]
        {
            Path.Combine(BaseDataFolder, "img1"),
            Path.Combine(BaseDataFolder, "img2"),
            Path.Combine(BaseDataFolder, "img3")
        };

        // 初始化所有必要的文件夹
        public void InitializeFolders()
        {
            // 确保基础数据文件夹存在
            if (!Directory.Exists(BaseDataFolder))
            {
                Directory.CreateDirectory(BaseDataFolder);
            }

            // 确保CSV文件夹存在
            if (!Directory.Exists(CsvFolder))
            {
                Directory.CreateDirectory(CsvFolder);
            }

            // 确保所有图片文件夹存在
            foreach (var folder in ImageFolders)
            {
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
            }
        }
    }
}
